package ${package.Controller};


import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.beans.factory.annotation.Autowired;
import ${cfg.packageName}.service.I${entity}Service;
<#if restControllerStyle>
import org.springframework.web.bind.annotation.RestController;
<#else>
import org.springframework.stereotype.Controller;
</#if>
import com.mti.framework.core.util.BeanTools;
import ${cfg.packageName}.model.bean.${entity}ListReq;
import ${cfg.packageName}.model.bean.${entity}ListForPageReq;
import ${cfg.packageName}.model.bean.${entity}SaveReq;
import ${cfg.packageName}.model.bean.${entity}DelReq;
import ${cfg.packageName}.model.bean.${entity}Req;
import ${cfg.packageName}.model.dto.${entity}DTO;
import ${cfg.packageName}.model.dto.${entity}SaveDTO;
import ${cfg.packageName}.model.vo.${entity}VO;
import com.mti.framework.core.bean.PageableOut;
import io.swagger.annotations.ApiOperation;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import javax.validation.Valid;
import java.util.List;
import io.swagger.annotations.Api;
/**
 * <p>
 * ${table.comment!} 前端控制器
 * </p>
 *
 * @author ${author}
 * @since ${date}
 */
<#if restControllerStyle>
@RestController
<#else>
@Controller
</#if>
@RequestMapping("/api<#if package.ModuleName?? && package.ModuleName != "">/${package.ModuleName}</#if>/<#if controllerMappingHyphenStyle??>${controllerMappingHyphen}<#else>${table.entityPath}</#if>")
<#if kotlin>
class ${table.controllerName}<#if superControllerClass??> : ${superControllerClass}()</#if>
<#else>
@Api(value="${table.comment!}控制层接口${table.controllerName}",tags={"${table.comment!}"})
<#if superControllerClass??>
public class ${table.controllerName} extends ${superControllerClass} {
<#else>
public class ${table.controllerName} {
</#if>

    @Autowired
    ${table.serviceName} ${table.entityPath}Service;

    @ApiOperation(value = "获取${table.comment!}列表信息", notes = "获取${table.comment!}列表信息")
    @PostMapping("/get${entity}List")
    public List<${entity}VO> get${entity}List(@RequestBody ${entity}ListReq ${table.entityPath}ListReq) {
        return ${table.entityPath}Service.get${entity}List(${table.entityPath}ListReq);
    }

    @ApiOperation(value = "获取${table.comment!}分页列表信息", notes = "获取${table.comment!}分页列表信息")
    @PostMapping("/get${entity}ListPage")
    public PageableOut<${entity}VO> get${entity}ListPage(@RequestBody ${entity}ListForPageReq ${table.entityPath}ListForPageReq) {
        return ${table.entityPath}Service.get${entity}ListPage(${table.entityPath}ListForPageReq);
    }

    @ApiOperation(value = "保存${table.comment!}信息", notes = "保存${table.comment!}信息")
    @PostMapping("/saveOrUpdate${entity}")
    public Boolean saveOrUpdate${entity}(@RequestBody @Valid ${entity}SaveReq ${table.entityPath}SaveReq) {
        ${entity}SaveDTO ${table.entityPath}SaveDTO = BeanTools.copy(${entity}SaveDTO.class, ${table.entityPath}SaveReq);
        return ${table.entityPath}Service.saveOrUpdate${entity}(${table.entityPath}SaveDTO);
    }

    @ApiOperation(value = "批量保存${table.comment!}信息", notes = "批量保存${table.comment!}信息")
    @PostMapping("/batchSave${entity}")
    public Integer batchSave${entity}(@RequestBody @Valid List<${entity}SaveReq> ${table.entityPath}SaveReqs) {
        List<${entity}SaveDTO> ${table.entityPath}SaveDTOS = BeanTools.copy(${entity}SaveDTO.class, ${table.entityPath}SaveReqs);
        return ${table.entityPath}Service.batchSave${entity}(${table.entityPath}SaveDTOS);
    }


    @ApiOperation(value = "删除${table.comment!}信息", notes = "删除${table.comment!}信息")
    @PostMapping("/delete${entity}")
    public Boolean delete${entity}(@RequestBody ${entity}DelReq ${table.entityPath}DelReq) {
        return ${table.entityPath}Service.delete${entity}ById(${table.entityPath}DelReq);
    }

    @ApiOperation(value = "获取${table.comment!}明细", notes = "获取${table.comment!}明细")
    @PostMapping("/get${entity}")
    public ${entity}VO get${entity}(@RequestBody ${entity}Req ${table.entityPath}Req) {
        ${entity}DTO ${table.entityPath}DTO = BeanTools.copy(${entity}DTO.class, ${table.entityPath}Req);
        return ${table.entityPath}Service.get${entity}(${table.entityPath}DTO);
    }

}
</#if>
